﻿Public Class FormAlbumDisplay
	Public prevForm As Form

	Public Function LoadAlbum(ByVal name As String, ByVal artist As String, ByVal mbid As String) As Boolean
		Dim methodAlbumGetInfo = New AlbumGetInfo(artist, name, mbid, "", "")
		methodAlbumGetInfo.sendRequest()

		Dim response = methodAlbumGetInfo.getResponse()

		If Not IsNothing(response) Then
			If Not IsNothing(response.album.image) Then
				If response.album.image(2) <> Nothing Then
					PictureBoxImageArt.ImageLocation = response.album.image(2)
				Else
					PictureBoxImageArt.Image = My.Resources.image_unavailable01
				End If
			Else
				PictureBoxImageArt.Image = My.Resources.image_unavailable01
			End If
			LabelAlbum.Text = response.album.name
			LabelArtist.Text = response.album.artist
			LabelPlayCount.Text = response.album.playcount
			LabelListeners.Text = response.album.listeners
			LabelReleaseDate.Text = response.album.releaseDate
			LinkLabelURL.Text = response.album.url

			ModuleTrack.GenerateListView(response.album.tracks, ListViewTracks)
		Else
			Return False
		End If

		Dim methodAlbumGetShouts = New AlbumGetShouts(name, artist, "", "", 10, 1)
		methodAlbumGetShouts.sendRequest()
		Dim response2 = methodAlbumGetShouts.getResponse()

		If Not IsNothing(response2) Then
			ModuleShout.GenerateShouts(response2.shouts, FlowLayoutPanel1)
		End If


		Return True
	End Function

	Private Sub FormAlbumDisplay_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		If Not IsNothing(prevForm) Then
			prevForm.Show()
			prevForm = Nothing
		End If
	End Sub

	Private Sub ButtonGoBack_Click(sender As System.Object, e As System.EventArgs) Handles ButtonGoBack.Click
		Me.Close()
	End Sub

	Private Sub FormAlbumDisplay_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub LinkLabelURL_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabelURL.LinkClicked
		'Dim albumBrowser As System.Windows.Forms.WebBrowser
		'WebBrowser.Navigate(sender.ToString)
	End Sub
End Class